package szwolaiyun.paireach.com.szwolaizhuang.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;

import com.paireach.szwolaiyun.sz_util.SharedPreferencesUtil;

import szwolaiyun.paireach.com.szwolaizhuang.R;
import szwolaiyun.paireach.com.szwolaizhuang.net.MainRequest;


public class WelcomActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcom);
        final String name = SharedPreferencesUtil.getValue(this, SharedPreferencesUtil.USER_NAME);
        final String realName = SharedPreferencesUtil.getValue(this, SharedPreferencesUtil.REAL_NAME);
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                    if (!TextUtils.isEmpty(name))
                        handler.sendEmptyMessage(1);
                    else
                        handler.sendEmptyMessage(0);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == 0)
                startActivity(new Intent(WelcomActivity.this, LoginActivity.class));
            else
                startActivity(new Intent(WelcomActivity.this, MainActivity.class));
            finish();
        }
    };
}
